package com.ruoyi.monitor.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.monitor.domain.MonitorWeld;
import com.ruoyi.monitor.service.IMonitorWeldService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 焊接参数实时监控Controller
 * 
 * @author ruoyi
 * @date 2023-02-12
 */
@Controller
@RequestMapping("/monitor/weld")
public class MonitorWeldController extends BaseController
{
    private String prefix = "monitor/weld";

    @Autowired
    private IMonitorWeldService monitorWeldService;

    @RequiresPermissions("monitor:weld:view")
    @GetMapping()
    public String weld()
    {
        return prefix + "/weld";
    }

    /**
     * 查询焊接参数实时监控列表
     */
    @RequiresPermissions("monitor:weld:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MonitorWeld monitorWeld)
    {
        startPage();
        List<MonitorWeld> list = monitorWeldService.selectMonitorWeldList(monitorWeld);
        return getDataTable(list);
    }

    /**
     * 导出焊接参数实时监控列表
     */
    @RequiresPermissions("monitor:weld:export")
    @Log(title = "焊接参数实时监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MonitorWeld monitorWeld)
    {
        List<MonitorWeld> list = monitorWeldService.selectMonitorWeldList(monitorWeld);
        ExcelUtil<MonitorWeld> util = new ExcelUtil<MonitorWeld>(MonitorWeld.class);
        return util.exportExcel(list, "焊接参数实时监控数据");
    }

    /**
     * 新增焊接参数实时监控
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存焊接参数实时监控
     */
    @RequiresPermissions("monitor:weld:add")
    @Log(title = "焊接参数实时监控", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MonitorWeld monitorWeld)
    {
        return toAjax(monitorWeldService.insertMonitorWeld(monitorWeld));
    }

    /**
     * 修改焊接参数实时监控
     */
    @RequiresPermissions("monitor:weld:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MonitorWeld monitorWeld = monitorWeldService.selectMonitorWeldById(id);
        mmap.put("monitorWeld", monitorWeld);
        return prefix + "/edit";
    }

    /**
     * 修改保存焊接参数实时监控
     */
    @RequiresPermissions("monitor:weld:edit")
    @Log(title = "焊接参数实时监控", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MonitorWeld monitorWeld)
    {
        return toAjax(monitorWeldService.updateMonitorWeld(monitorWeld));
    }

    /**
     * 删除焊接参数实时监控
     */
    @RequiresPermissions("monitor:weld:remove")
    @Log(title = "焊接参数实时监控", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(monitorWeldService.deleteMonitorWeldByIds(ids));
    }
}
